<!DOCTYPE html>
<br>

<head>
  <meta charset="utf-8">
  <title>H5 Bridge Test</title>
  <style>
    button {
      width: 45rem;
      height: 6rem;
      font-size: 3rem;
    }

    input {
      width: 45rem;
      height: 5rem;
      font-size: 3rem;
    }

    label {
      font-size: 6rem;
    }

    a {
      font-size: 6rem;
    }
  </style>
</head>

<body>

  <label>Pasteboard Set and Get</label>
  <input id="pasteboardSet" type="text" placeholder="set" value="">
  </br>
  <input id="pasteboardGet" type="text" placeholder="get" value="">
  </br>
  <button type="button" onclick="pasteboardSet()">set</button>
  </br>
  <button type="button" onclick="pasteboardGet()">get</button>
  </br>
  </br>
  <label>Toast</label>
  </br>
  <button type="button" onclick="toast()">Toast</button>
  </br>
  </br>
  </br>
  <label>LoadingHud</label>
  </br>
  <button type="button" onclick="showHUD()">show</button>
  </br>
  </br>
  <label>Set NavigationBar</label>
  </br>
  <button type="button" onclick="setTitle()">setTitle</button>
  </br>
  </br>
  <button type="button" onclick="setStyle()">setStyle</button>
  </br>
  </br>
  <button type="button" onclick="setNavigationBar()">setNavigationBar</button>
  </br>
  </br>

</body>

<script type="text/javascript">
  (function() {
    window.pasteboardSet = () => {
      console.log("pasteboardSet")
      const text = document.getElementById("pasteboardSet").value;
      taro.Phone.Pasteboard.set(text);
    };

    window.pasteboardGet = () => {
      console.log("pasteboardGet");
      var cb = function(params) {
        var text = params["result"]["text"]
        document.getElementById("pasteboardGet").value = text
        alert(text)
      };
      taro.Phone.Pasteboard.get(cb);
    };

    window.toast = () => {
      console.log("toast");
      taro.NativeUI.Toast.show("this is toast");
    };
    window.showHUD = () => {
      console.log("show HUD");
      taro.NativeUI.LoadingDialog.show("1.5s to hide");
      setTimeout(function() {
        console.log("hide HUD");
        taro.NativeUI.LoadingDialog.hide();
      }, 1500);
    };
    window.setTitle = () => {
      console.log("setTitle");
      taro.NativeUI.NavigationBar.setup("JS Title");
    };
    window.setStyle = () => {
      console.log("setStyle");
      taro.NativeUI.NavigationBar.setup(null, "black");
    };
    window.setNavigationBar = () => {
      console.log("setNavigationBar");
      taro.NativeUI.NavigationBar.setup("JS Title", "black", {
        "text": "退出",
        "target_url": "pop"
      }, true);
    }
  })();
</script>

</html>
